home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 July / CHIP 2006-07.2.iso / program / web_gelistirme / easyphp1-7_setup.exe / {app} / phpmyadmin / server_status.php < prev    next >
Encoding:
PHP Script  |  2003-09-07  |  14.1 KB  |  307 lines

  1. <?php
  2. /* $Id: server_status.php,v 1.11 2003/08/10 20:10:37 lem9 Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * Does the common work
  8.  */
  9. require('./server_common.inc.php');
  10.  
  11.  
  12. /**
  13.  * Displays the links
  14.  */
  15. require('./server_links.inc.php');
  16.  
  17.  
  18. /**
  19.  * InnoDB status
  20.  */
  21. if (!empty($innodbstatus)) {
  22.     echo '<h2>' . "\n"
  23.        . '    ' . $strInnodbStat . "\n"
  24.        . '</h2>' . "\n";
  25.     $sql_query = 'SHOW INNODB STATUS;';
  26.     $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
  27.     $row = PMA_mysql_fetch_row($res);
  28.     echo '<pre>' . "\n"
  29.        . htmlspecialchars($row[0]) . "\n"
  30.        . '</pre>' . "\n";
  31.     mysql_free_result($res);
  32.     include('./footer.inc.php');
  33.     exit;
  34. }
  35.  
  36. /**
  37.  * Displays the sub-page heading
  38.  */
  39. echo '<h2>' . "\n"
  40.    . '    ' . $strServerStatus . "\n"
  41.    . '</h2>' . "\n";
  42.  
  43.  
  44. /**
  45.  * Checks if the user is allowed to do what he tries to...
  46.  */
  47. if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
  48.     echo $strNoPrivileges;
  49.     include('./footer.inc.php');
  50.     exit;
  51. }
  52.  
  53.  
  54. /**
  55.  * Sends the query and buffers the result
  56.  */
  57. $res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
  58. while ($row = PMA_mysql_fetch_row($res)) {
  59.     $serverStatus[$row[0]] = $row[1];
  60. }
  61. @mysql_free_result($res);
  62. unset($res);
  63. unset($row);
  64.  
  65.  
  66. /**
  67.  * Displays the page
  68.  */
  69. //Uptime calculation
  70. $res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
  71. $row = PMA_mysql_fetch_row($res);
  72. echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
  73. mysql_free_result($res);
  74. unset($res);
  75. unset($row);
  76. //Get query statistics
  77. $queryStats = array();
  78. $tmp_array = $serverStatus;
  79. while (list($name, $value) = each($tmp_array)) {
  80.     if (substr($name, 0, 4) == 'Com_') {
  81.         $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
  82.         unset($serverStatus[$name]);
  83.     }
  84. }
  85. unset($tmp_array);
  86. ?>
  87. <ul>
  88.     <li>
  89.         <!-- Server Traffic -->
  90.         <?php echo $strServerTrafficNotes; ?><br />
  91.         <table border="0">
  92.             <tr>
  93.                 <td valign="top">
  94.                     <table border="0">
  95.                         <tr>
  96.                             <th colspan="2"> <?php echo $strTraffic; ?> </th>
  97.                             <th> ø <?php echo $strPerHour; ?> </th>
  98.                         </tr>
  99.                         <tr>
  100.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strReceived; ?> </td>
  101.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?> </td>
  102.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?> </td>
  103.                         </tr>
  104.                         <tr>
  105.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strSent; ?> </td>
  106.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?> </td>
  107.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?> </td>
  108.                         </tr>
  109.                         <tr>
  110.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
  111.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?> </td>
  112.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?> </td>
  113.                         </tr>
  114.                     </table>
  115.                 </td>
  116.                 <td valign="top">
  117.                     <table border="0">
  118.                         <tr>
  119.                             <th colspan="2"> <?php echo $strConnections; ?> </th>
  120.                             <th> ø <?php echo $strPerHour; ?> </th>
  121.                             <th> % </th>
  122.                         </tr>
  123.                         <tr>
  124.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strFailedAttempts; ?> </td>
  125.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  126.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  127.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td>
  128.                         </tr>
  129.                         <tr>
  130.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strAbortedClients; ?> </td>
  131.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  132.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  133.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td>
  134.                         </tr>
  135.                         <tr>
  136.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
  137.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  138.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  139.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?> % </td>
  140.                         </tr>
  141.                     </table>
  142.                 </td>
  143.             </tr>
  144.         </table>
  145.     </li>
  146.     <br />
  147.     <li>
  148.         <!-- Queries -->
  149.         <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
  150.         <table border="0">
  151.             <tr>
  152.                 <td colspan="2">
  153.                     <br />
  154.                     <table border="0" align="right">
  155.                         <tr>
  156.                             <th> <?php echo $strTotalUC; ?> </th>
  157.                             <th> ø <?php echo $strPerHour; ?> </th>
  158.                             <th> ø <?php echo $strPerMinute; ?> </th>
  159.                             <th> ø <?php echo $strPerSecond; ?> </th>
  160.                         </tr>
  161.                         <tr>
  162.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  163.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  164.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  165.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  166.                         </tr>
  167.                     </table>
  168.                 </td>
  169.             </tr>
  170.             <tr>
  171.                 <td valign="top">
  172.                     <table border="0">
  173.                         <tr>
  174.                             <th colspan="2"> <?php echo $strQueryType; ?> </th>
  175.                             <th> ø <?php echo $strPerHour; ?> </th>
  176.                             <th> % </th>
  177.                         </tr>
  178. <?php
  179.  
  180. $useBgcolorOne = TRUE;
  181. $countRows = 0;
  182. while (list($name, $value) = each($queryStats)) {
  183.  
  184. // For the percentage column, use Questions - Connections, because
  185. // the number of connections is not an item of the Query types
  186. // but is included in Questions. Then the total of the percentages is 100. 
  187. ?>
  188.                         <tr>
  189.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars($name); ?> </td>
  190.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  191.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  192.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 100 / ($serverStatus['Questions'] - $serverStatus['Connections'])), 2, $number_decimal_separator, $number_thousands_separator); ?> % </td>
  193.                         </tr>
  194. <?php
  195.     $useBgcolorOne = !$useBgcolorOne;
  196.     if (++$countRows == ceil(count($queryStats) / 2)) {
  197.         $useBgcolorOne = TRUE;
  198. ?>
  199.                     </table>
  200.                 </td>
  201.                 <td valign="top">
  202.                     <table border="0">
  203.                         <tr>
  204.                             <th colspan="2"> <?php echo $strQueryType; ?> </th>
  205.                             <th> ø <?php echo $strPerHour; ?> </th>
  206.                             <th> % </th>
  207.                         </tr>
  208. <?php
  209.     }
  210. }
  211. unset($countRows);
  212. unset($useBgcolorOne);
  213. ?>
  214.                     </table>
  215.                 </td>
  216.             </tr>
  217.         </table>
  218.     </li>
  219. <?php
  220. //Unset used variables
  221. unset($serverStatus['Aborted_clients']);
  222. unset($serverStatus['Aborted_connects']);
  223. unset($serverStatus['Bytes_received']);
  224. unset($serverStatus['Bytes_sent']);
  225. unset($serverStatus['Connections']);
  226. unset($serverStatus['Questions']);
  227. unset($serverStatus['Uptime']);
  228.  
  229. if (!empty($serverStatus)) {
  230. ?>
  231.     <br />
  232.     <li>
  233.         <!-- Other status variables -->
  234.         <b><?php echo $strMoreStatusVars; ?></b><br />
  235.         <table border="0">
  236.             <tr>
  237.                 <td valign="top">
  238.                     <table border="0">
  239.                         <tr>
  240.                             <th> <?php echo $strVar; ?> </th>
  241.                             <th> <?php echo $strValue; ?> </th>
  242.                         </tr>
  243. <?php
  244.     $useBgcolorOne = TRUE;
  245.     $countRows = 0;
  246.     while (list($name, $value) = each($serverStatus)) {
  247. ?>
  248.                         <tr>
  249.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?> </td>
  250.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo htmlspecialchars($value); ?> </td>
  251.                         </tr>
  252. <?php
  253.         $useBgcolorOne = !$useBgcolorOne;
  254.         if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
  255.             $useBgcolorOne = TRUE;
  256. ?>
  257.                     </table>
  258.                 </td>
  259.                 <td valign="top">
  260.                     <table border="0">
  261.                         <tr>
  262.                             <th> <?php echo $strVar; ?> </th>
  263.                             <th> <?php echo $strValue; ?> </th>
  264.                         </tr>
  265. <?php
  266.         }
  267.     }
  268.     unset($useBgcolorOne);
  269. ?>
  270.                     </table>
  271.                 </td>
  272.             </tr>
  273.         </table>
  274.     </li>
  275. <?php
  276. }
  277. $res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink);
  278. if ($res) {
  279.     $row = PMA_mysql_fetch_row($res);
  280.     if (!empty($row[1]) && $row[1] == 'YES') {
  281. ?>
  282.     <br />
  283.     <li>
  284.         <!-- InnoDB Status -->
  285.         <a href="./server_status.php?<?php echo $url_query; ?>&innodbstatus=1">
  286.             <b><?php echo $strInnodbStat; ?></b>
  287.         </a>
  288.     </li>
  289. <?php
  290.     }
  291. } else {
  292.     unset($res);
  293. }
  294. ?>
  295. </ul>
  296.  
  297.  
  298. <?php
  299.  
  300.  
  301. /**
  302.  * Sends the footer
  303.  */
  304. require('./footer.inc.php');
  305.  
  306. ?>
  307.